from arq.connections import RedisSettings
from app.core.config import settings
from app.core.arq_tasks import process_doi_list,process_jiangsu,process_ylqx_bn,process_ylqx_bn_detail, test_abc, startup, shutdown

# ARQ Worker配置
class WorkerSettings:
    # 注册任务函数
    functions = [process_doi_list,process_jiangsu, process_ylqx_bn,process_ylqx_bn_detail,test_abc]
    
    # 启动和关闭钩子
    on_startup = startup
    on_shutdown = shutdown
    
    # Redis连接设置
    redis_settings = RedisSettings(
        host=settings.REDIS_HOST,
        port=settings.REDIS_PORT,
        password=settings.REDIS_PASSWORD,
        database=0
    )
    
    # 其他配置
    max_jobs = 10
    job_timeout = 3600*24*30  # 将超时时间从1小时(3600) 
    keep_result_forever = False
    max_tries = 1  # 设置为1表示不重试任务
    retry_jobs = False  # 禁用任务重试

if __name__ == "__main__":
    import sys
    import os
    sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))